package ControlLayer;

import ModelLayer.*;
import DBLayer.*;

import java.util.ArrayList;

public class SupplierCtrl 
{
	public SupplierCtrl() 
	{
        
    }
    
	public ArrayList<Supplier> getAllSupplier()
    {
		IfDbSupplier dbSupplier = new DbSupplier();
		ArrayList<Supplier> allSupplier = new ArrayList<Supplier>();
		allSupplier = dbSupplier.getAllSupplier(false);
		return allSupplier;
    }
    
	public Supplier findSupplierByName(String name)
    {
        IfDbSupplier dbSupplier = new DbSupplier();
        return dbSupplier.findSupplierByName(name, true);
    }
	
	public Supplier findSupplierByID(int id)
    {
        IfDbSupplier dbSupplier = new DbSupplier();
        return dbSupplier.findSupplierByID(id, true);
    }
	
	public int updateSupplier(String name, String address, String zipCode, String phoneNr, String country, String email)
    {
		IfDbSupplier dbSupplier = new DbSupplier();
        Supplier supplier = new Supplier();
        supplier.setName(name);
        supplier.setAddress(address);
        supplier.setZipCode(zipCode);
        supplier.setPhoneNr(phoneNr);
        supplier.setCountry(country);
        supplier.setEmail(email);
        return  dbSupplier.updateSupplier(supplier);
    }
	
	
}
